package com.sinosoft.sm.user.web.dto;

import java.io.Serializable;
import java.util.Date;
import java.util.List;

import com.sinosoft.sm.system.common.SystemContants;
import com.sinosoft.sm.system.common.utils.ObjectUtil;
import com.sinosoft.sm.system.role.dto.RoleData;
import com.sinosoft.sm.user.entity.UserEntity;

/**
 * 用户信息实体类
 * @author leichao
 *
 */
public class UserData implements Serializable{

	private static final long serialVersionUID = 1L;
	
    private String username;		//用户名（唯一标识）

	private String loginName;
	
    private String name;		//真实姓名

    private String gender;		//性别
    
    private String telephone;   //电话

    private String salt;    //盐值
    
    private String password;  //密码
    
    private String group;   //组别
    
    private String roleid;   //角色标识
    
    private String state;     //用户状态  0：禁用  1启用
    
    private String creater;		//创建人

    private Date createtime;		//创建时间

    private String updater;		//	修改人

    private Date updatetime;		//修改时间
    
    private List<RoleData> roles;
    
    private int page;	//	当前页
    
	private int rows;	//	数据大小

	public String getUsername() {
		return username;
	}

	public void setUsername(String username) {
		this.username = username;
		this.loginName = username;
	}
	
	public String getLoginName() {
		return loginName;
	}

	public void setLoginName(String loginName) {
		this.loginName = loginName;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getGender() {
		return gender;
	}

	public void setGender(String gender) {
		if(SystemContants.USER_GENDER_MAN.equals(gender)){
			this.gender = "男";
		}else if(SystemContants.USER_GENDER_WOMAN.equals(gender)){
			this.gender = "女";
		}else{
			this.gender = gender;
		}
	}

	public String getTelephone() {
		return telephone;
	}

	public void setTelephone(String telephone) {
		this.telephone = telephone;
	}

	public String getSalt() {
		return salt;
	}

	public void setSalt(String salt) {
		this.salt = salt;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public String getRoleid() {
		return roleid;
	}

	public void setRoleid(String roleid) {
		this.roleid = roleid;
	}

	public String getState() {
		return state;
	}

	public void setState(String state) {
		if(SystemContants.USER_STATE_ON.equals(state)){
			this.state = "启用";
		}else if(SystemContants.USER_STATE_OFF.equals(state)){
			this.state = "禁用";
		}else{
			this.state = state;
		}
	}

	public String getCreater() {
		return creater;
	}

	public void setCreater(String creater) {
		this.creater = creater;
	}

	public Date getCreatetime() {
		return createtime;
	}

	public void setCreatetime(Date createtime) {
		this.createtime = createtime;
	}

	public String getUpdater() {
		return updater;
	}

	public void setUpdater(String updater) {
		this.updater = updater;
	}

	public Date getUpdatetime() {
		return updatetime;
	}

	public void setUpdatetime(Date updatetime) {
		this.updatetime = updatetime;
	}
	
	public String getGroup() {
		return group;
	}

	public void setGroup(String group) {
		this.group = group;
	}

	public List<RoleData> getRoles() {
		return roles;
	}

	public void setRoles(List<RoleData> roles) {
		this.roles = roles;
	}

	
	public int getPage() {
		return page;
	}

	public void setPage(int page) {
		this.page = page;
	}

	public int getRows() {
		return rows;
	}

	public void setRows(int rows) {
		this.rows = rows;
	}

	/**
	 * 数据转换
	 * 实体类转传输类
	 * @param userEntity	用户实体数据
	 */
	public void toUserData(UserEntity userEntity) {
		ObjectUtil.oldToNew(this, userEntity, "serialVersionUID");
	}
	
	/**
	 * 数据转换
	 * 传输类转实体类
	 * @return	用户实体数据
	 */
	public UserEntity toUserEntity() {
		UserEntity userEntity = new UserEntity();
		ObjectUtil.oldToNew(userEntity, this, "serialVersionUID");
		return userEntity;
	}
    
}
